package com.longteng.diamond.factory;

import com.longteng.diamond.dao.BaseMapper;
import com.longteng.diamond.dao.ProjectHostMapper;
import com.longteng.diamond.dao.ProjectMemberMapper;
import com.longteng.diamond.dao.ProjectModuleMapper;
import com.longteng.diamond.service.ProjectShareInterface;
import com.longteng.diamond.service.impl.ProjectHostInterface;
import com.longteng.diamond.service.impl.ProjectMemberInterface;
import com.longteng.diamond.service.impl.ProjectModuleInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator
 * DATE : 2018/7/26
 * TIME : 21:27
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:taki@qq.com">Administrator</a>
 */
@Component
public class ProjectShareFactory {
    @Autowired
    ProjectMemberMapper projectMemberMapper;
    @Autowired
    ProjectModuleMapper projectModuleMapper;
    @Autowired
    ProjectHostMapper projectHostMapper;
    @Autowired
    ProjectHostInterface projectHostInterface;
    @Autowired
    ProjectMemberInterface projectMemberInterface;
    @Autowired
    ProjectModuleInterface projectModuleInterface;
    /**
     * 通过传过来的类型获取对应的mapper
     * @param shareType
     * @return BaseMapper
     */
    public BaseMapper baseMapper(int shareType){
        BaseMapper baseMapper=null;
        switch (shareType) {
            case 1:
                baseMapper = projectMemberMapper;
                break;
            case 2:
                baseMapper = projectHostMapper;
                break;
            case 3:
                baseMapper = projectModuleMapper;
                break;
            default:
                break;
        }
        return baseMapper;
    }
    /**
     * 通过传过来的类型获取对应的service
     * @param shareType
     * @return BaseMapper
     */
    public ProjectShareInterface projectShareInterface(int shareType){
        ProjectShareInterface projectShareInterface=null;
        switch (shareType) {
            case 1:
                projectShareInterface =projectMemberInterface;
                break;
            case 2:
                projectShareInterface = projectHostInterface;
                break;
            case 3:
                projectShareInterface=projectModuleInterface;
                break;
            default:
                break;
        }
        return projectShareInterface;
    }
}
